<script>
	import Vue from 'vue'
	export default {
		onLaunch: function() {
			const self = this
			const updateManager = uni.getUpdateManager()
			updateManager.onCheckForUpdate(function(res) {
				// 请求完新版本信息的回调
				console.log(res.hasUpdate)
			})
			// 下载新版本
			updateManager.onUpdateReady(function() {
				uni.showModal({
					title: '更新提示',
					content: '新版本已经准备好，是否重启应用？',
					success(res) {
						if (res.confirm) {
							// 重启应用
							updateManager.applyUpdate()
						}
					}
				})
			})
			// 新版本下载失败
			updateManager.onUpdateFailed(function(res) {
				// 新的版本下载失败
				uni.showModal({
					title: '已经有新版本了哟~',
					content: '新版本已经上线啦~，请您删除当前小程序，重新搜索打开哟~',
				})

			})
			
			// #ifdef MP-WEIXIN
			// 获取当前小程序的appId
			const accountInfo = uni.getAccountInfoSync();
			console.log("appId", accountInfo.miniProgram.appId); // 小程序 appId
			// #endif
			uni.onNetworkStatusChange(function (res) {
				console.log("网络测试")
				if (res.isConnected) {
					console.log(">>>有网络了")
					// self.$yrouter.reLaunch({
					// 	path: "/pages/launch/index"
					// });
				}
			});
		},
		onShow: function() {
			console.log("App Show");
		},
		onHide: function() {
			console.log("App Hide");
		},
		mounted() {
			this.setAppInfo()
		},
		methods: {
			// 获取系统栏高度
			async setAppInfo() {
				let that = this;
				return new Promise((resolve, reject) => {
					uni.getSystemInfo({
						success: function(e) {
							Vue.prototype.StatusBar = e.statusBarHeight;
							// #ifdef H5
							Vue.prototype.CustomBar = e.statusBarHeight + 45;
							// #endif

							// #ifdef APP-PLUS
							if (e.platform == "android") {
								Vue.prototype.CustomBar = e.statusBarHeight + 50;
							} else {
								Vue.prototype.CustomBar = e.statusBarHeight + 45;
							}
							// #endif

							// #ifdef MP-WEIXIN
							let custom = wx.getMenuButtonBoundingClientRect();
							Vue.prototype.Custom = custom;
							Vue.prototype.CustomBar =
								custom.bottom + custom.top - e.statusBarHeight;
							// #endif
						},
					});
				});
			}
		}
	};
</script>


<style lang="less">
	/*每个页面公共css */
	@import "animate.css";
	@import "./assets/iconfont/iconfont.css";
	@import "./assets/css/base.less";
	@import "./assets/css/reset.less";
	@import "./assets/css/style.less";

	@import "./style/grid.css";
	.uni-tag-btn {
		height: 35rpx;
		line-height: calc(35rpx);
		padding: 0px 7px;
		font-size: 12px;
		border-radius: 15px !important;
		background: linear-gradient(38deg, #9f2b45, #F8895A) !important;
		border-color: inherit;
		color: #fff;
		margin-right: 15rpx;
	
	}
	.img-covor {
		width: 100%;
		height: 100%;
		position: relative;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		border-radius: 8rpx;
	}
	.img-back-covor {
		background-repeat: no-repeat;
		background-size: cover;
		background-position: center center; 
	}

	// 角标样式
	.silk-ribbon4 {
		position: absolute;
		top: 0;
		padding: 6rpx 20rpx 6rpx 10rpx;
		background: #9f2b45;
		box-shadow: -1px 2px 4px rgba(0, 0, 0, 0.5);
		color: #fff;
		font-size: 12px;
	}

	.silk-ribbon4:before,
	.silk-ribbon4:after {
		position: absolute;
		content: "";
		display: block;
	}

	.silk-ribbon4:before {
		width: 7px;
		height: 100%;
		padding: 0 0 7px;
		top: 0;
		left: -7px;
		background: inherit;
		border-radius: 5px 0 0 5px;
	}
 

	.silk-ribbon4:after {
		width: 5px;
		height: 5px;
		background: rgba(0, 0, 0, 0.35);
		bottom: -5px;
		left: -5px;
		border-radius: 5px 0 0 5px;
	}


	.custom-tag {
		border-radius: 4px 4px 4px 0px;
		color: #fff;
		padding: 2px 6px;
		font-size: 10px;
		line-height: 16px;
		background: linear-gradient(to right bottom, rgba(255, 255, 255, 0.4), transparent) var(--bg, #EA3447);
		background-blend-mode: soft-light;
	}

	.custom-tag::before {
		content: '';
		position: absolute;
		width: 3px;
		height: 3px;
		left: 0;
		bottom: -3px;
		background-color: inherit;
		filter: brightness(.7);
		clip-path: polygon(0 0, 100% 0, 100% 100%);
	}
</style>